package cn.redragon.soa.data.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.GenericGenerator;

@Data
@MappedSuperclass
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class IdEntity implements Serializable {

    private static final long serialVersionUID = 2955886978738326171L;

    @Id
    @GenericGenerator(name = "assigned_id", strategy = "cn.redragon.soa.common.web.entity.AssignedIdentityGenerator")
    @GeneratedValue(generator = "assigned_id", strategy = GenerationType.IDENTITY)
    @Column(length = 12)
    protected Long id;

    public boolean isNew() {
        return this.id == null;
    }
}

